## README

This repository contains replication files for reproducing the analysis results reported in Joan Barceló, Jeffrey L. Jensen, Leonid Peisakhin, and Haoyu Zhai (2024), "New Estimates of U.S. Civil War Mortality From Full-Census Records." Users are advised to download all R scripts and data files (XLSX) and run each script sequentially, from `R_01*.R` to `R_03*.R`, to fully reproduce the statistics and graphics presented in the paper. All files should be placed in the same directory to ensure the relative paths are correctly set for the main analysis.

### Included R Scripts:

- `R_01_estimate_deaths_national.R`: Computes nationwide excess mortality estimates for native-born white males, as well as all white and adult males of fighting age, between 1860 and 1870 as a result of the Civil War. This is done using the sex-differential method on aggregated full-count census data. The output is `EST_excdeaths_national.xlsx`.

- `R_02_estimate_deaths_bystate.R`: Computes state-level excess mortality estimates for native-born white males of fighting age between 1860 and 1870, using the migration-adjusted method on aggregated full-count and linked census data. The outputs are `EST_excdeaths_count_bystate.xlsx` (excess headcounts) and `EST_excdeaths_rate_bystate.xlsx` (excess rates).

- `R_03_make_tables_graphs.R`: Produces Figure 1 and Tables 1-2 from the paper. This script uses the three output XLSX files as inputs and generates in-script tables (manually compiled into TEX format for the paper) as well as a plot, viewable in-session and exported to PNG or TIFF files for inclusion in the paper.

- `R_suppl_prepare_census_data.R`: Prepares both the full-count and linked censuses of 1850, 1860, 1870, and 1880. This script takes raw data files downloaded from the IPUMS online portal (matching XML and DAT.GIZ files) and generates XLSX files containing summary statistics by cohort and sex at the desired geographic level (nationwide and state-level). [Note: Due to IPUMS policies prohibiting the redistribution of full-count data, no raw data is provided in this repository. Interested users should download the full-count or one-percent raw data files from IPUMS and use the script to generate summary statistics for analysis. The code is provided here for completeness and transparency but is not intended for parsing by default.]

### Data Files:

The XLSX files starting with 'DAT' contain summary statistics computed from full-count and linked census samples. These are used as inputs to generate the final estimates found in the 'EST'-prefixed XLSX files. The data are pre-aggregated at the national and state levels for the respective analysis. The XLSX file named 'DICT_state_battleside.xlsx' contains paired entries for each state and its corresponding side in the Civil War, which are used to group states for the state-level analysis.

(Last edited: 2024-09-25)
